package com.ruoyi.web.controller.employee;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.employee.domain.HrHeatPlan;
import com.ruoyi.employee.service.IHrHeatPlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 高温费方案Controller
 * 
 * @author ruoyi
 * @date 2025-10-11
 */
@RestController
@RequestMapping("/employee/thermal")
public class HrHeatPlanController extends BaseController
{
    @Autowired
    private IHrHeatPlanService hrHeatPlanService;

    /**
     * 查询高温费方案列表
     */
    @PreAuthorize("@ss.hasPermi('employee:thermal:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrHeatPlan hrHeatPlan)
    {
        startPage();
        List<HrHeatPlan> list = hrHeatPlanService.selectHrHeatPlanList(hrHeatPlan);
        return getDataTable(list);
    }

    /**
     * 导出高温费方案列表
     */
    @PreAuthorize("@ss.hasPermi('employee:thermal:export')")
    @Log(title = "高温费方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrHeatPlan hrHeatPlan)
    {
        List<HrHeatPlan> list = hrHeatPlanService.selectHrHeatPlanList(hrHeatPlan);
        ExcelUtil<HrHeatPlan> util = new ExcelUtil<HrHeatPlan>(HrHeatPlan.class);
        util.exportExcel(response, list, "高温费方案数据");
    }

    /**
     * 获取高温费方案详细信息
     */
    @PreAuthorize("@ss.hasPermi('employee:thermal:query')")
    @GetMapping(value = "/{planId}")
    public AjaxResult getInfo(@PathVariable("planId") String planId)
    {
        return success(hrHeatPlanService.selectHrHeatPlanByPlanId(planId));
    }

    /**
     * 新增高温费方案
     */
    @PreAuthorize("@ss.hasPermi('employee:thermal:add')")
    @Log(title = "高温费方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrHeatPlan hrHeatPlan)
    {
        return toAjax(hrHeatPlanService.insertHrHeatPlan(hrHeatPlan));
    }

    /**
     * 修改高温费方案
     */
    @PreAuthorize("@ss.hasPermi('employee:thermal:edit')")
    @Log(title = "高温费方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrHeatPlan hrHeatPlan)
    {
        return toAjax(hrHeatPlanService.updateHrHeatPlan(hrHeatPlan));
    }

    /**
     * 删除高温费方案
     */
    @PreAuthorize("@ss.hasPermi('employee:thermal:remove')")
    @Log(title = "高温费方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planIds}")
    public AjaxResult remove(@PathVariable String[] planIds)
    {
        return toAjax(hrHeatPlanService.deleteHrHeatPlanByPlanIds(planIds));
    }
}
